package com.dy.controller;

import com.dy.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @projectName: day0612_1
 * @package: com.dy.controller
 * @className: SugarController
 * @author: DuanYu
 * @description: TODO
 * @date: 2024/6/12 19:37
 * @version: 1.0
 */
@RestController
public class SugarController {
    @Autowired
    SugarService service;
    @RequestMapping("/listDay")
    public Map showDay(){
        Double aDouble = service.showDay();
        Map map = new HashMap<>();
       map.put("status",0);
       map.put("data",aDouble);
       return map;
    }
    @RequestMapping("/listXd")
    public Map showXd(){
        return SugarUtil.getPieData(service.showXd());
    }
    @RequestMapping("/listJg")
    public String showJg(){
       List list =  new ArrayList<>();
       list.add("机构");
       list.add("完成里程");
       list.add("完运次数");
       list.add("每次平均时长");
       list.add("每次平均里程");
        return SugarUtil.getTablePlayData(list,service.showJg());
    }
    @RequestMapping("/listMap")
    public Map showMap(){
        return SugarUtil.getMapData(service.showMap());
    }
}
